﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using StoreClientModule;
using System.Drawing.Printing;
using uCoreClasses;
using UnityScriptEngine;


namespace MBBStoreClient
{
    public partial class frmDailySales : Form
    {

        UnityProcessor proc = new UnityProcessor();
        Threader thr = new Threader();
        UnityScript[] dat = new UnityScript[0];
        DataTable records = new DataTable();
        DataTable dates = new DataTable();
        DataTable cDates = new DataTable();
        DataTable items = new DataTable();
        DataTable check = new DataTable();
        DataTable finalResult = new DataTable();


        string dateFilter;
        string[] arrDate;
        string myDay;
        string myMonth;
        string myYear;


        DailySales ds = new DailySales();
        uThreader t = new uThreader();
        DataTable dt = new DataTable();
        int curLoaded = 0;
        int cL = 0;
        public frmDailySales()
        {
            InitializeComponent();

            btnClose.Click += new EventHandler(btnClose_Click);
            panel2.EnabledChanged += new EventHandler(panel2_EnabledChanged);

            ds.ProcessCompleted += new ModuleEventHandler(ds_ProcessCompleted);
            ds.ProcessError += new ModuleEventHandler(ds_ProcessError);

            btnLoad.Click += new EventHandler(btnLoad_Click);
            btnPrint.Click += new EventHandler(btnPrint_Click);

            proc.ProcessCompleted += new ProcessHandler(proc_ProcessCompleted);
            proc.ProcessError += new ProcessHandler(proc_ProcessError);
            thr.MethodCompleted += new EventHandler(thr_MethodCompleted);
        }

        void thr_MethodCompleted(object sender, EventArgs e)
        {
            thr.SafeCall(this, delegate
            {
                switch (sender.ToString())
                {
                    case "CreateDataTable":
                        grdReport.DataSource = finalResult;
                        //
                        pnlMsg.Visible = false;
                        btnLoad.Enabled = true;
                        btnPrint.Enabled = true;
                        txtDate.Enabled = true;
                        txtView.Enabled = true;
                        grdReport.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        curLoaded = 3;
                    break;
                }
            });
        }

        void proc_ProcessError(string id, string desc)
        {
            thr.SafeCall(this, delegate
            {
                MessageBox.Show(desc);
            });
        }

        void proc_ProcessCompleted(string id, string desc)
        {
            thr.SafeCall(this, delegate
            {
                switch (id)
                {

                    case "SEARCH":
                        proc.DBPUX_Data_Fetch(out dat);
                        records = dat[0].ToDataTable();
                        dates= dat[1].ToDataTable();
                        items = dat[2].ToDataTable();
                        check = dat[3].ToDataTable();
                        cDates = dat[4].ToDataTable();
                        

                        thr.MethodCall(CreateDataTable);

                        
                        break;
                }
            });
        }

        void Search()
        {
            while (proc.IsRunning) { }
            proc.ProcStart();
            UnityScript u = new UnityScript("SEARCH", 4);

            u.Script_Add(Script.DBPUX_BEGIN);
            u.Script_Add(Script.DBPUX_QUERY, string.Format("SELECT fID, fDate, fInvoice, fStamp FROM tblSalesDetail WHERE fDate LIKE '" + myMonth + "%" + myYear + "' AND fInvoiceType = 'Sales'"));
            u.Script_Add(Script.DBPUX_QUERY, string.Format("SELECT DISTINCT fDate FROM tblSalesDetail WHERE fDate LIKE '" + myMonth + "%" + myYear + "' AND fInvoiceType = 'Sales' ORDER BY fDate ASC "));
            u.Script_Add(Script.DBPUX_QUERY, string.Format("SELECT fID, fQty, fUnitPrice, fInvoice, fStamp FROM tblSalesItem"));
            u.Script_Add(Script.DBPUX_QUERY, string.Format("SELECT fID, fDateReceived, fAmount, fStamp FROM tblcheque WHERE fDateReceived LIKE '" + myMonth + "%" + myYear + "'"));
            u.Script_Add(Script.DBPUX_QUERY, string.Format("SELECT DISTINCT fDateReceived FROM tblCheque WHERE fDateReceived LIKE '" + myMonth + "%" + myYear + "'"));
            u.Script_Add(Script.DBPUX_COMMIT);
            proc.Run(u);
        }

        void CreateDataTable()
        {
            double totalAmount = 0.0;
            finalResult = new DataTable();
            finalResult.Columns.Add("Date");
            finalResult.Columns.Add("Total Amount");

            if (dates.Rows.Count == 0)
            {
                for (int i = 0; i < cDates.Rows.Count; i++)
                {
                    totalAmount = 0.0;
                    DataRow dr = finalResult.NewRow();
                    string ondate = cDates.Rows[i][0].ToString();
                    dr[0] = DateTime.Parse(ondate).ToString("MM-dd-yyyy");

                    for (int j = 0; j < check.Rows.Count; j++)
                    {
                        if (ondate.Equals(check.Rows[j]["fDateReceived"].ToString()))
                        {
                            double amtC = double.Parse(check.Rows[j]["fAmount"].ToString());
                            totalAmount += amtC;
                        }
                    }
                    dr[1] = totalAmount.ToString("#,#0.00");
                    finalResult.Rows.Add(dr);
                }
            }
            else
            {

                for (int i = 0; i < dates.Rows.Count; i++)
                {
                    totalAmount = 0.0;
                    DataRow dr = finalResult.NewRow();
                    string ondate = dates.Rows[i][0].ToString();
                    dr[0] = DateTime.Parse(ondate).ToString("MM-dd-yyyy");

                    for (int j = 0; j < records.Rows.Count; j++)
                    {
                        if (ondate.Equals(records.Rows[j]["fDate"].ToString()))
                        {
                            string invoice = records.Rows[j]["fInvoice"].ToString();
                            for (int k = 0; k < items.Rows.Count; k++)
                            {
                                if (invoice.Equals(items.Rows[k]["fInvoice"].ToString()))
                                {
                                    double qty = double.Parse(items.Rows[k]["fQty"].ToString());
                                    double price = double.Parse(items.Rows[k]["fUnitPrice"].ToString());
                                    double amt = qty * price;
                                    totalAmount += amt;
                                }
                            }
                        }
                    }
                    for (int l = 0; l < check.Rows.Count; l++)
                    {
                        if (ondate.Equals(check.Rows[l]["fDateReceived"].ToString()))
                        {
                            double amtC = double.Parse(check.Rows[l]["fAmount"].ToString());
                            totalAmount += amtC;
                        }
                    }

                    dr[1] = totalAmount.ToString("#,#0.00");
                    finalResult.Rows.Add(dr);
                }
            }
            finalResult.DefaultView.Sort = "Date";
        }
        //old approach
        void btnPrint_Click(object sender, EventArgs e)
        {
            
            if (grdReport.Rows.Count > 0)
            {
                PrintList();
            }
        }
        void PrintList()
        {
            PrintDocument pd = new PrintDocument();
            pd.DocumentName = lblText.Text;
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
            PrintDialog pdlg = new PrintDialog();
            pdlg.Document = pd;
            if (pdlg.ShowDialog() == DialogResult.OK)
            {
                PrintPreviewDialog ppdlg = new PrintPreviewDialog();
                ppdlg.Document = pd;
                ppdlg.ShowDialog();
            }
        }
        void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            float lpp = 0;
            float y = 0;
            float tm = e.MarginBounds.Top;
            float lm = e.PageBounds.Left + 150;
            float lw = e.PageBounds.Width - 150;
            float th = e.PageBounds.Height - 100;
            float tHt = 0;

            float grandTotal = 0.0f;
            Font cFont;
            StringFormat sf = new StringFormat();
            //Start Printing here
            cFont = new Font("Arial", 8f, FontStyle.Regular);
            tHt = cFont.GetHeight(e.Graphics);
            y = 50;
            tHt = cFont.GetHeight(e.Graphics);
            sf.Alignment = StringAlignment.Near;
            if (curLoaded == 0)
            {
                lpp = (th - y) / tHt;
                int i = 0, cl=0;
                while (cl <= lpp && i < dt.Rows.Count)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        int m = j % 2;
                        int xf = 0;
                        //Alignment
                        if (m == 1)
                        {
                            sf.Alignment = StringAlignment.Far;
                            xf = 50;
                        }
                        else
                        {
                            sf.Alignment = StringAlignment.Near;
                        }
                        //Header
                        if (i < 2 || i == dt.Rows.Count - 1)
                        {
                            cFont = new Font("Arial", 8f, FontStyle.Bold);
                            e.Graphics.DrawRectangle(new Pen(Brushes.Black), lm, y, lm + (60 * (dt.Columns.Count-1)), tHt);
                        }
                        else
                        {
                            cFont = new Font("Arial", 8f, FontStyle.Regular);
                        }
                        e.Graphics.DrawString(dt.Rows[i][j].ToString(), cFont, Brushes.Black, lm + (60 * j) + xf, y, sf);
                        if (i > 1 & m == 0) e.Graphics.DrawLine(new Pen(Brushes.Black), lm + (60 * j), y, lm + (60 * j), y + tHt);
                        if (j == dt.Columns.Count - 1) e.Graphics.DrawLine(new Pen(Brushes.Black), lm + (60 * j) + xf, y, lm + (60 * j) + xf, y + tHt);
                    }

                    y += tHt;
                    i++;
                    cl++;
                    cL = i;
                }
                
            }
            if (curLoaded == 1)
            {
                lpp = (th - y) / tHt;
                int i = 0, cl = 0;
                while (cl <= lpp && i < dt.Rows.Count)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        int m = j % 2;
                        int xf = 0;
                        //Alignment
                        if (m == 1)
                        {
                            sf.Alignment = StringAlignment.Far;
                            xf = 50;
                        }
                        else
                        {
                            sf.Alignment = StringAlignment.Near;
                        }
                        //Header
                        if (i < 1)
                        {
                            cFont = new Font("Arial", 8f, FontStyle.Bold);
                            e.Graphics.DrawRectangle(new Pen(Brushes.Black), lm, y, lm + (360 * (dt.Columns.Count - 1)), tHt);
                        }
                        else
                        {
                            cFont = new Font("Arial", 8f, FontStyle.Regular);
                        }
                        e.Graphics.DrawString(dt.Rows[i][j].ToString(), cFont, Brushes.Black, lm + (360 * j) + xf, y, sf);

                        if (i > 0 & m == 0) e.Graphics.DrawLine(new Pen(Brushes.Black), lm + (360 * j), y, lm + (360 * j), y + tHt);
                        if (j == dt.Columns.Count - 1) e.Graphics.DrawLine(new Pen(Brushes.Black), lm + (360 * j) + xf, y, lm + (360 * j) + xf, y + tHt);
                        if (i == dt.Rows.Count - 1) e.Graphics.DrawLine(new Pen(Brushes.Black), lm, y + tHt, lm + (360 * j) + xf, y + tHt);
                    }

                    y += tHt;
                    i++;
                    cl++;
                    cL = i;
                }

            }
            if (curLoaded == 2)
            {
                lpp = (th - y) / tHt;
                int i = 0, cl = 0;
                while (cl <= lpp && i < dt.Rows.Count)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        int xf = 0;
                        int spc = 120;
                        //Alignment
                        if (j == 2 || j == 5)
                        {
                            sf.Alignment = StringAlignment.Far;
                            xf = 50;
                            if (j == 5) e.Graphics.DrawLine(new Pen(Brushes.Black), lm + (spc * j) + xf, y, lm + (spc * j) + xf, y + tHt);
                        }
                        else if(j == 0 || j == 3)
                        {
                            sf.Alignment = StringAlignment.Near;
                            if (j == 3) e.Graphics.DrawLine(new Pen(Brushes.Black), lm + (spc * j) + xf, y, lm + (spc * j) + xf, y + tHt);
                        }
                        //Header
                        if (i < 2)
                        {
                            cFont = new Font("Arial", 8f, FontStyle.Bold);
                            e.Graphics.DrawRectangle(new Pen(Brushes.Black), lm, y, lm + (spc * (dt.Columns.Count - 1)), tHt);
                        }
                        else
                        {
                            cFont = new Font("Arial", 8f, FontStyle.Regular);
                        }
                        if (i > 1)
                        {
                            e.Graphics.DrawLine(new Pen(Brushes.Black), lm, y, lm, y + tHt);

                        }
                        if (i == dt.Rows.Count - 1) e.Graphics.DrawLine(new Pen(Brushes.Black), lm, y + tHt, lm + (spc * j) + xf, y + tHt);
                        if (j == 1)
                        {
                            spc = 160;
                        }
                        if (j == 4)
                        {
                            spc = 130;
                        }
                        e.Graphics.DrawString(dt.Rows[i][j].ToString(), cFont, Brushes.Black, lm + (spc * j) + xf, y, sf);
                        
                    }

                    y += tHt;
                    i++;
                    cl++;
                    cL = i;
                }
            }
            if (curLoaded == 3)
            {
                y = 150;

                cFont = new Font("Courier New", 12f, FontStyle.Bold);
                tHt = cFont.GetHeight(e.Graphics);
                sf.Alignment = StringAlignment.Center;
                e.Graphics.DrawString(Common.lStoreName, new Font("Courier New", 15f, FontStyle.Bold), Brushes.Black, e.PageBounds.Width / 2, 50, sf);
                e.Graphics.DrawString(Common.lStoreAddress, new Font("Courier New", 15f, FontStyle.Bold), Brushes.Black, e.PageBounds.Width / 2, 70, sf);
                e.Graphics.DrawString("Monthly Report for the month of "+DateTime.Parse(txtDate.Text).ToString("MMMM")+ " - " +myYear, new Font("Courier New", 15f, FontStyle.Bold), Brushes.Black, e.PageBounds.Width / 2, 90, sf);
                e.Graphics.DrawString("Daily Sales ", new Font("Courier New", 15f, FontStyle.Bold), Brushes.Black, e.PageBounds.Width / 2, 110, sf);

                e.Graphics.FillRectangle(Brushes.LightGray, lm, y, lw - lm, tHt);
                e.Graphics.DrawRectangle(new Pen(Brushes.Black), lm, y, lw - lm, tHt);

                sf.Alignment = StringAlignment.Center;
                float cx = lm + (((lw - lm) * 50) / 100);
                float tx = lm + (((lw - lm) * 25f) / 100);
                e.Graphics.DrawLine(new Pen(Brushes.Black), cx, y, cx, y + tHt);
                e.Graphics.DrawString("Date", cFont, Brushes.Black, tx, y, sf);

                cx += ((lw - lm) * 50) / 100;
                tx = cx - ((lw - lm) * 50) / 200;
                e.Graphics.DrawLine(new Pen(Brushes.Black), cx, y, cx, y + tHt);
                e.Graphics.DrawString("Amount", cFont, Brushes.Black, tx, y, sf);

                y += tHt;
                y += tHt;
                lpp = (th - y) / tHt;
                int i = 0, cl = 0;
                float stx = 0.0f;
                while (cl <= lpp && i < finalResult.Rows.Count)
                {
                    sf.Alignment = StringAlignment.Near;
                    stx = lm + 10;
                    e.Graphics.DrawString(grdReport.Rows[i].Cells[0].Value.ToString(), cFont, Brushes.Black, stx, y, sf);
                    sf.Alignment = StringAlignment.Far;
                    stx += ((lw - lm) * 95) / 100;
                    e.Graphics.DrawString(grdReport.Rows[i].Cells[1].Value.ToString(), cFont, Brushes.Black, stx, y, sf);


                    float amt = float.Parse(grdReport.Rows[i].Cells[1].Value.ToString());
                    grandTotal += amt;

                    y += tHt;
                    i++;
                    cl++;
                }

                cL = i;
            }
            
            //If Has more pages
            if (cL < dt.Rows.Count - 1)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                y += tHt;

                if (curLoaded == 3)
                {
                    sf.Alignment = StringAlignment.Near;
                    float stx = lm + 10;
                    e.Graphics.DrawString("Total", cFont, Brushes.Black, stx, y, sf);
                    sf.Alignment = StringAlignment.Far;
                    stx += ((lw - lm) * 95) / 100;
                    e.Graphics.DrawString(grandTotal.ToString("#,#0.00"), cFont, Brushes.Black, stx, y, sf);
                }

            }
        }

        void btnLoad_Click(object sender, EventArgs e)
        {
            pnlMsg.Visible = true;
            btnLoad.Enabled = false;
            btnPrint.Enabled = false;
            txtDate.Enabled = false;
            txtView.Enabled = false;

            if (txtView.SelectedIndex == 0)
            {
                ds.Get(txtDate.Text);
            }
            if (txtView.SelectedIndex == 1)
            {
                ds.GetItem(txtDate.Text);
            }
            if (txtView.SelectedIndex == 2)
            {
                ds.GetAccount(txtDate.Text);
            }
            //additional
            if (txtView.SelectedIndex == 3)
            {
                this.Enabled = false;
                dateFilter = txtDate.Text;
                arrDate = dateFilter.Split('/');
                myDay = int.Parse(arrDate[1].Trim()).ToString();
                myMonth = int.Parse(arrDate[0].Trim()).ToString();
                myYear = int.Parse(arrDate[2].Trim()).ToString();
                Search();
            }
        }
        void ds_ProcessCompleted(string procCode, string msg)
        {
            t.SafeCall(this, delegate
            {
                if(procCode == "Get")FillGrid(ds.SalesList);
                if (procCode == "GetItem") FillGridItems(ds.ItemList);
                if (procCode == "GetAccount") FillGridAccount(ds.AccountList);
                pnlMsg.Visible = false;
                btnLoad.Enabled = true;
                btnPrint.Enabled = true;
                txtDate.Enabled = true;
                txtView.Enabled = true;
            });
        }
        void ds_ProcessError(string procCode, string msg)
        {
            t.SafeCall(this, delegate
            {
                MessageBox.Show(msg, "Daily Sales", MessageBoxButtons.OK, MessageBoxIcon.Error);
                pnlMsg.Visible = false;
                btnLoad.Enabled = true;
                btnPrint.Enabled = true;
                txtDate.Enabled = true;
                txtView.Enabled = true;
            });
        }
        void FillGrid(DailySalesType[] dst)
        {
            //Build the columns and initialize values
            dt.Rows.Clear();
            dt.Columns.Clear();
            for (int i = 0; i < dst.Length * 2; i++)
            {
                dt.Columns.Add();
            }
            DataRow dr1 = dt.NewRow();
            for (int i = 0; i < dst.Length; i++)
            {
                dr1[i*2] = dst[i].fSalesman;
                
            }
            dt.Rows.Add(dr1);
            DataRow dr2 = dt.NewRow();
            for (int i = 0; i < dst.Length; i++)
            {
                dr2[i*2] = "Invoice #";
                dr2[(i*2) + 1] = "Amount";
                dst[i].fTotal = "0";
                grdReport.Columns[i * 2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                grdReport.Columns[(i * 2) + 1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                grdReport.Columns[i * 2].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            }
            dt.Rows.Add(dr2);
            if (grdReport.Rows.Count > 0)
            {
                grdReport.Rows[0].DefaultCellStyle.BackColor = Color.Yellow;
                grdReport.Rows[1].DefaultCellStyle.BackColor = Color.Gray;
            }
            //Load the data.
            int curL = 0;
            bool hasMore = false;
            do
            {
                DataRow dr = dt.NewRow();
                hasMore = false;
                for (int i = 0; i < dst.Length; i++)
                {
                    if (curL < dst[i].fSale.Length)
                    {
                        dr[i * 2] = dst[i].fSale[curL].fInvoice;
                        dr[(i * 2) + 1] = dst[i].fSale[curL].fAmount;
                        dst[i].fTotal = (float.Parse(dst[i].fTotal) + float.Parse(dst[i].fSale[curL].fAmount)).ToString();
                        hasMore = true;
                    }
                }
                curL++;
                if(hasMore)dt.Rows.Add(dr);
            } while (hasMore);

            DataRow dr3 = dt.NewRow();
            for (int i = 0; i < dst.Length; i++)
            {
                dr3[i * 2] = "Total";
                dr3[(i * 2) + 1] = Common.FormatCurrency(dst[i].fTotal);
            }
            dt.Rows.Add(dr3);
            if (grdReport.Rows.Count > 0)
            {
                int ind = grdReport.Rows.Count - 1;
                grdReport.Rows[ind].DefaultCellStyle.Font = new Font("Courier New", 12f, FontStyle.Bold);
            }
            curLoaded = 0;
        }
        void FillGridItems(DataTable dst)
        {
            dt = new DataTable();
            dt.Columns.Add("Description");
            dt.Columns.Add("Quantity");
            DataRow dr1 = dt.NewRow();
            dr1["Description"] = "Description";
            dr1["Quantity"] = "Quantity";
            dt.Rows.Add(dr1);
            for (int i = 0; i < dst.Rows.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr["Description"] = dst.Rows[i]["Description"];
                dr["Quantity"] = dst.Rows[i]["Quantity"];
                dt.Rows.Add(dr);
            }

            grdReport.DataSource = dt;
            if (grdReport.Rows.Count > 0)
            {
                grdReport.Rows[0].DefaultCellStyle.BackColor = Color.Yellow;
            }
            grdReport.Columns[0].Width = (grdReport.Width * 40) / 100;
            grdReport.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            curLoaded = 1;
        }
        void FillGridAccount(DataTable dst)
        {
            dt = new DataTable();
            for (int i = 0; i < 6; i++)
            {
                dt.Columns.Add();
            }
            DataRow dr1 = dt.NewRow();
            dr1[0] = "SALES";
            dr1[1] = "ACCOUNT";

            dr1[3] = "CHARGED";
            dr1[4] = "ACCOUNT";

            dt.Rows.Add(dr1);
            DataRow dr2 = dt.NewRow();
            dr2[0] = "Customer's Name";
            dr2[1] = "Invoices";
            dr2[2] = "Amount";
            dr2[3] = "Customer's Name";
            dr2[4] = "OR #";
            dr2[5] = "Amount";
            dt.Rows.Add(dr2);
            for (int i = 0; i < dst.Rows.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = dst.Rows[i][0];
                dr[1] = dst.Rows[i][1];
                dr[2] = Common.FormatCurrency(dst.Rows[i][2].ToString());
                dr[3] = dst.Rows[i][3];
                dr[4] = dst.Rows[i][4];
                dr[5] = Common.FormatCurrency(dst.Rows[i][5].ToString());
                dt.Rows.Add(dr);
            }
            grdReport.DataSource = dt;
            if (grdReport.Rows.Count > 0)
            {
                grdReport.Rows[0].DefaultCellStyle.BackColor = Color.Gray;
                grdReport.Rows[1].DefaultCellStyle.BackColor = Color.Yellow;
            }
            grdReport.Columns[0].Width = (grdReport.Width * 20) / 100;
            grdReport.Columns[3].Width = (grdReport.Width * 20) / 100;
            grdReport.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            grdReport.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            curLoaded = 2;
        }

        void panel2_EnabledChanged(object sender, EventArgs e)
        {
            if (!panel2.Enabled)
            {
                panel2.BackColor = Color.MidnightBlue;
            }
            else
            {
                panel2.BackColor = Color.RoyalBlue;
            }
        }
        void btnClose_Click(object sender, EventArgs e)
        {
            pnlForm.Dispose();
            this.Dispose();
        }
        public Panel PanelForm
        {
            get { return pnlForm; }
        }
        public void Initialize(string Title)
        {
            this.Select();
            lblText.Text = Title;
            grdReport.DataSource = dt;
            grdReport.Font = new Font("Courier New", 12f);

            txtView.Items.Add("by Salesman");
            txtView.Items.Add("by Item");
            txtView.Items.Add("by Account");
            txtView.Items.Add("Monthly Report");
            txtView.SelectedItem = txtView.Items[0];
        }
    }
}
